
import html5ShowModal from './show-modal';

// #ifdef APP-PLUS
/** 屏幕宽度 */
const { windowWidth } = uni.getSystemInfoSync();

/** 是否平板 */
const isPinBan = windowWidth > 480;


/** 原来的 uni.showToast */
const oldUniShowToast = uni.showToast;

/** 重写 uni.showToast */
uni.showToast = (options: UniApp.ShowToastOptions) => {
	if (isPinBan) {
		plus.nativeUI.toast(`<font style="font-size: 36px">${options.title}</font>`, { 
			icon: options.icon, 
			type: 'richtext', verticalAlign: 'center' ,
			duration: options.duration as unknown as "long" | "short",
		});
		
		return;
	};
	
	oldUniShowToast(options);
};


/** 原来的 */
const oldUniShowModal = uni.showModal;

/** 重写 uni.showModal */
uni.showModal = (options: UniApp.ShowModalOptions) => {
	if (isPinBan) {
		/** html5 showModal */
		const { open } = html5ShowModal(options);
		open();
		return;
	};
	
	oldUniShowModal(options);
};
// #endif


export default {};